package com.example.demo.business.service;

import com.example.demo.base.util.CommonUtil;
import com.example.demo.business.bean.dto.VideoListDto;
import com.example.demo.business.bean.entity.HVideo;
import com.example.demo.business.bean.vo.BestCategoryVo;
import com.example.demo.business.bean.vo.IndexCategoryVo;
import com.example.demo.business.dao.HBestCategoryDao;
import com.example.demo.business.dao.HIndexCategoryDao;
import com.example.demo.business.dao.HVideoDao;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@Service
public class CategoryService {
    @Autowired
    private HIndexCategoryDao hIndexCategoryDao;
    @Autowired
    private HBestCategoryDao hBestCategoryDao;

    @Autowired
    private HVideoDao hVideoDao;

    //获取首页的分类
    public Object getIndexCategory(int type){
        return hIndexCategoryDao.findByTypeOrderBySorts(type).stream().map(item->{
            IndexCategoryVo indexCategoryVo = new IndexCategoryVo();
            BeanUtils.copyProperties(item,indexCategoryVo);
            return indexCategoryVo;
        });
//        IndexCategoryVo
    }
    //获取最佳的的分类
    public Object getBestCategory(int type){
        return hBestCategoryDao.findByTypeOrderBySorts(type).stream().map(item->{
            BestCategoryVo indexCategoryVo = new BestCategoryVo();
            BeanUtils.copyProperties(item,indexCategoryVo);
            indexCategoryVo.setImg(item.getImg());
            indexCategoryVo.setCname(item.getCName());
            return indexCategoryVo;
        });
    }


}
